/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.demo.repository.entity;

import com.gitee.peigenlpy.actable.annotation.Column;
import com.gitee.peigenlpy.actable.annotation.Index;
import com.gitee.peigenlpy.actable.annotation.Table;
import com.gitee.peigenlpy.actable.annotation.Unique;
import com.gitee.peigenlpy.actable.constants.MySqlCharsetConstant;
import com.gitee.peigenlpy.actable.constants.MySqlEngineConstant;
import com.gitee.peigenlpy.actable.constants.MySqlTypeConstant;
import com.gitee.peigenlpy.sansheng.core.annotation.ColumnField;
import info.peigen.hotpot.business.account.facade.enums.AccountStatus;
import info.peigen.hotpot.business.account.facade.enums.AccountType;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.common.core.enums.Currency;
import info.peigen.hotpot.common.core.lang.money.Money;
import info.peigen.hotpot.component.data.repository.beetlsql.entity.AbstractCreateTimeEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.handler.MoneyBeetlSqlHandler;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

/**
 * <b>(AccountEntity)</b>
 * 账户表
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/1
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
@Table(name = "account", comment = "账户表", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
@org.beetl.sql.annotation.entity.Table(name = "account")
public class AccountEntity extends AbstractCreateTimeEntity {
    @ColumnField(change = false)
    @Column(name = "customer_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "客户Id")
    @Index(value = "customerId", columns = "customer_id")
    @org.beetl.sql.annotation.entity.Column("customer_id")
    String        customerId;
    @ColumnField(change = false)
    @Column(name = "account_id", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "账户Id")
    @Unique(value = "accountId", columns = "account_id")
    @org.beetl.sql.annotation.entity.Column("account_id")
    String        accountId;
    @Column(name = "account_type", type = MySqlTypeConstant.VARCHAR, length = 20, isNull = false,
            comment = "账户类型;Customer:客户账户,Provisions:备付金账户,Card:卡,System:系统账户")
    @Index(value = "accountType", columns = "account_type")
    @org.beetl.sql.annotation.entity.Column("account_type")
    AccountType   accountType;
    @Column(name = "status", type = MySqlTypeConstant.VARCHAR, length = 20, isNull = false,
            comment = "账户状态;Init:初始化,Normal:正常账户,Freeze:账户被冻结,Abandon:账户被废弃")
    @Index(value = "status", columns = "status")
    @org.beetl.sql.annotation.entity.Column("status")
    AccountStatus status;
    @ColumnField(change = false)
    @Builder.Default
    @Column(name = "currency", type = MySqlTypeConstant.VARCHAR, length = 3, isNull = false, comment = "币种")
    @Index(value = "currency", columns = "currency")
    @org.beetl.sql.annotation.entity.Column("currency")
    Currency      currency = Currency.CNY;
    @ColumnField(change = false)
    @Column(name = "balance", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "余额")
    @org.beetl.sql.annotation.entity.Column("balance")
    @MoneyBeetlSqlHandler
    Money         balance;
    @Column(name = "alias_name", type = MySqlTypeConstant.VARCHAR, length = 300, comment = "账户别名")
    @org.beetl.sql.annotation.entity.Column("alias_name")
    String        aliasName;
    @Column(name = "channel_code", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "渠道编码")
    @Index(value = "channelCode", columns = "channel_code")
    @org.beetl.sql.annotation.entity.Column("channel_code")
    ChannelCode   channelCode;
    @ColumnField(change = false)
    @Column(name = "freeze_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "冻结资金")
    @org.beetl.sql.annotation.entity.Column("freeze_amount")
    @MoneyBeetlSqlHandler
    Money         freezeAmount;
    @ColumnField(change = false)
    @Column(name = "transit_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "在途资金")
    @org.beetl.sql.annotation.entity.Column("transit_amount")
    @MoneyBeetlSqlHandler
    Money         transitAmount;
    @Column(name = "credit_quota_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "信用额度")
    @org.beetl.sql.annotation.entity.Column("credit_quota_amount")
    @MoneyBeetlSqlHandler
    Money         creditQuotaAmount;
    @ColumnField(change = false)
    @Column(name = "pending_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "待入账金额")
    @org.beetl.sql.annotation.entity.Column("pending_amount")
    @MoneyBeetlSqlHandler
    Money         pendingAmount;
    @ColumnField(change = false)
    @Column(name = "history_income_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "历史收入总金额")
    @org.beetl.sql.annotation.entity.Column("history_income_amount")
    @MoneyBeetlSqlHandler
    Money         historyIncomeAmount;
    @ColumnField(change = false)
    @Column(name = "history_paid_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "历史支出总金额")
    @org.beetl.sql.annotation.entity.Column("history_paid_amount")
    @MoneyBeetlSqlHandler
    Money         historyPaidAmount;
    @Column(name = "memo", type = MySqlTypeConstant.VARCHAR, length = 200, comment = "备注")
    @org.beetl.sql.annotation.entity.Column("memo")
    String        memo;
}